home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / misc / libx11.lha / libX11 / visuals.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-22  |  3.8 KB  |  143 lines

  1. /* Copyright (c) 1996 by Terje Pedersen.  All Rights Reserved   */
  2. /*                                                              */
  3. /* By using this code you will agree to these terms:            */
  4. /*                                                              */
  5. /* 1. You may not use this code for profit in any way or form   */
  6. /*    unless an agreement with the author has been reached.     */
  7. /*                                                              */
  8. /* 2. The author is not responsible for any damages caused by   */
  9. /*    the use of this code.                                     */
  10. /*                                                              */
  11. /* 3. All modifications are to be released to the public.       */
  12. /*                                                              */
  13. /* Thats it! Have fun!                                          */
  14. /* TP                                                           */
  15. /*                                                              */
  16.  
  17. /***
  18.    NAME
  19.      visuals
  20.    PURPOSE
  21.      
  22.    NOTES
  23.      
  24.    HISTORY
  25.      Terje Pedersen - Jul 6, 1995: Created.
  26. ***/
  27.  
  28. #include "libX11.h"
  29.  
  30. #include <libraries/asl.h>
  31. #include <proto/asl.h>
  32.  
  33. #include <dos.h>
  34. #include <signal.h>
  35. #include <stdlib.h>
  36. #include <stdio.h>
  37.  
  38. #define XLIB_ILLEGAL_ACCESS 1
  39.  
  40. #include <X11/X.h>
  41. #include <X11/Xlib.h>
  42.  
  43. #include <X11/Xutil.h>
  44. #include <X11/Intrinsic.h>
  45. #include <X11/IntrinsicP.h>
  46. #include <X11/CoreP.h>
  47.  
  48. #include <X11/Xlibint.h>
  49.  
  50. #include "amigax_proto.h"
  51.  
  52. extern struct IntuitionBase *IntuitionBase;
  53. extern struct GfxBase *GfxBase;
  54. extern struct Library *AslBase;
  55. extern struct Library *GadToolsBase;
  56. extern struct Library *DiskfontBase;
  57. extern struct Library *LayersBase;
  58. extern struct DosLibrary *DOSBase;
  59.  
  60. extern int usewb;
  61.  
  62. Visual  amiga_visual;
  63. Visual X11AmigaVisual[2];
  64.  
  65. XFreeVisualInfo(Display *display, XVisualInfo *vis){
  66.   free(vis);
  67. }
  68.  
  69. XVisualInfo *X11vis;
  70.  
  71. void X11SetupVisual(void){
  72.   int i;
  73.   /* fill the visual info with something meaningfull */
  74.   for(i=0;i<2;i++){
  75.     X11AmigaVisual[i].visualid=i;
  76.     X11AmigaVisual[i].class=PseudoColor;
  77.     X11AmigaVisual[i].red_mask=0x800;
  78.     X11AmigaVisual[i].green_mask=0x080;
  79.     X11AmigaVisual[i].blue_mask=0x008;
  80.     X11AmigaVisual[i].bits_per_rgb=8;
  81.   }
  82.   X11AmigaVisual[0].map_entries=1<<DG.nDisplayDepth;
  83.   X11AmigaVisual[1].map_entries=1<<DG.nDisplayMaxDepth;
  84. }
  85.  
  86. XVisualInfo *XGetVisualInfo(display, vinfo_mask,
  87.                 vinfo_template, nitems_return)
  88.      Display *display;
  89.      long vinfo_mask;
  90.      XVisualInfo *vinfo_template;
  91.      int *nitems_return;
  92. {
  93.   int vis_num=2,i,n=0;
  94. #ifdef DEBUGXEMUL
  95.   printf("XGetVisualInfo\n");
  96. #endif
  97. /*
  98.   if(usewb) vis_num=1;
  99.   *nitems_return=vis_num;
  100. */
  101.   X11vis=(XVisualInfo*)malloc(sizeof(XVisualInfo)*vis_num);
  102.   for(i=0;i<vis_num;i++){ 
  103. /*    if(vinfo_mask&VisualScreenMask && vinfo_template->screen!=i) continue;*/
  104.     if(vinfo_mask&VisualIDMask && vinfo_template->visualid!=i) continue;
  105.     
  106.     X11vis[n].visual=&X11AmigaVisual[i];
  107.     X11vis[n].visualid=i;
  108.     X11vis[n].screen=i;
  109.     X11vis[n].class=PseudoColor/*StaticColor*/;
  110.     X11vis[n].red_mask=0x800;
  111.     X11vis[n].green_mask=0x080;
  112.     X11vis[n].blue_mask=0x008;
  113.     X11vis[n].bits_per_rgb=8;
  114.     n++;
  115.   }
  116.   X11vis[0].depth=DG.nDisplayDepth;
  117.   X11vis[0].colormap_size=1<<DG.nDisplayDepth;
  118.   X11vis[1].depth=DG.nDisplayMaxDepth;
  119.   X11vis[1].colormap_size=1<<DG.nDisplayMaxDepth;
  120. /*
  121.   if(!usewb){
  122.     X11vis[0].colormap_size=1<<DG.nDisplayMaxDepth;
  123.     X11vis[1].depth=DG.nDisplayMaxDepth;
  124.   }*/
  125.   *nitems_return=n;
  126.   return(X11vis);
  127. }
  128.  
  129. VisualID XVisualIDFromVisual(visual)
  130.      Visual *visual;
  131. {
  132.   if(visual) return(visual->visualid);
  133.   return(0);
  134. }
  135.  
  136. Visual *XDefaultVisual(Display *d,int n){/*          File 'x11perf.o'*/
  137. #ifdef DEBUGXEMUL
  138.   printf("XDefaultVisual\n");
  139. #endif
  140.   if(n==0) return(&X11AmigaVisual[0]);
  141.   return(&X11AmigaVisual[1]);
  142. }
  143.